package engine.groups.other
{
	import ash.core.Entity;
	
	import engine.GameEngine;
	import engine.groups.Group;
	import engine.managers.ScreenManager;
	import engine.systems.control.motionControl.MotionControlSystem;
	import engine.systems.render.render.Render;
	import engine.systems.spatial.sleep.Sleep;
	import engine.systems.spatial.spatial.Spatial;
	import engine.systems.spatial.spatialToMouse.SpatialToMouse;
	import engine.systems.spatial.spatialToMouse.SpatialToMouseSystem;
	import engine.utils.GraphicUtils;
	
	import flash.display.Shape;
	
	public class CursorGroup extends Group
	{
		public static const CURSOR_ENTITY_NAME:String = "Cursor";
		
		public function CursorGroup(parent:Group)
		{
			super(parent);
			
			this.setupCursor();
		}
		
		private function setupCursor():void
		{
			this.addSystem(new SpatialToMouseSystem());
			this.addSystem(new MotionControlSystem());
			
			var cursor:Entity = new Entity(CursorGroup.CURSOR_ENTITY_NAME);
			this.addEntity(cursor);
			
			var shape:Shape = new Shape();
			shape.graphics.lineStyle(4, 0x333333);
			shape.graphics.beginFill(0xFFFFFF);
			GraphicUtils.drawArrow(shape.graphics);
			shape.graphics.endFill();
			shape.rotation = -120;
			
			cursor.add(new Render(shape, GameEngine.screenManager.foregroundContainer));
			cursor.add(new SpatialToMouse(GameEngine.screenManager.foregroundContainer));
			cursor.add(new Spatial());
			cursor.add(new Sleep(false, true, true));
		}
	}
}